package com.sport.setting.controller;

import com.sport.apis.annotation.SportStatus;
import com.sport.model.common.dtos.ResponseResult;
import com.sport.model.setting.dtos.*;
import com.sport.setting.service.SportEventsAlmightyService;
import com.sport.setting.service.SportMeetingDefineItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/SportSetting")
@SportStatus(sportTargetStatus = SportStatus.InnerStatus.ORGANIZE_SPORT_MEETING)
public class SportMeetingSettingController {

    @Resource
    SportMeetingDefineItemService sportMeetingSettingService;

    @Resource
    SportEventsAlmightyService sportEventsAlmightyService;

    /**
     * 自定义比赛项目
     * @param sportEventsGamesDtos
     * @return
     */
    @PostMapping("/define/Item")
    public ResponseResult defineCompetitionItem(@RequestBody @Validated List<SportEventsGamesDto> sportEventsGamesDtos) {
        sportEventsGamesDtos.forEach((value)->{
            sportMeetingSettingService.defineItem(value);
        });
        return ResponseResult.okResult("处理成功！");
    }

    /**
     * 删除自定义比赛项目
     * @return
     */
    @PostMapping("/delete/Item")
    public ResponseResult deleteItemProject(@RequestBody List<Long> deleteIds) {
        return sportMeetingSettingService.deleteItemProject(deleteIds);
    }

    /**
     * 自定义全能项目
     * @param sportEventsAlmightyDto
     * @return
     */
    @PostMapping("/Almighty/Item")
    public ResponseResult defineAlmightyItem(@RequestBody @Validated SportEventsAlmightyDto sportEventsAlmightyDto){
        return sportEventsAlmightyService.defineAlmightyItem(sportEventsAlmightyDto);
    }

    /**
     * 展示可选单人项目
     * @return
     */
    @GetMapping("/getEvents")
    public ResponseResult getEventsGame() {
        return sportMeetingSettingService.showEventsGame();
    }

    /**
     * 设置暂存
     * @return
     */
    @PostMapping("/set/temp")
    public ResponseResult setTempGameForSchool(SportEventsTempGameDto sportEventsTempGameDto) {
        return sportMeetingSettingService.setTempGameForSchool(sportEventsTempGameDto);
    }

    @GetMapping("/get/temp")
    public ResponseResult getTempGameForSchool() {
        return sportMeetingSettingService.getTempGameForSchool();
    }

    /**
     * 设置单人项目
     * @param sportEventsGamesChooseDtoList
     * @return
     */
    @PostMapping("/setEvents/grade")
    public ResponseResult setEventsGameForGrade(@RequestBody @Validated List<SportEventsGamesChooseDto> sportEventsGamesChooseDtoList) {
        return sportMeetingSettingService.setEventsGameForGrade(sportEventsGamesChooseDtoList);
    }

    /**
     * 显示比赛组及对应单位
     */
    @GetMapping("/Show/GradeAndUnit")
    public ResponseResult showGradeAndUnit() {
        return sportMeetingSettingService.showGradeAndUnit();
    }


    /**
     * 显示人数,给分配号码是作参考
     */
    @PostMapping("/Show/Quantity")
    public ResponseResult showQuantity(@RequestBody @Validated SportNumberShowDto sportNumberShowDto){
        return sportMeetingSettingService.showQuantity(sportNumberShowDto);
    }


    /**
     *号码分配
     */
    @PostMapping("/Assign/Number")
    public ResponseResult assignedNumber(@RequestBody @Validated SportNumberParamDto sportNumberParamDto){
        return sportMeetingSettingService.assignedNumber(sportNumberParamDto);
    }
}
